
/*
 * @Description: 
 * @Author: rendc
 * @Date: 2024-10-14 14:45:22
 * @LastEditors: rendc
 * @LastEditTime: 2024-10-14 16:22:41
 */
/**
 * Test04
 */
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class Test06 {

  public static void main(String[] args) throws IOException {
    // 1. 声明流
    // 文件输出流
    // FileOutputStream(path)
    // 2. 创建流
    InputStream inputStream = new FileInputStream("/Users/cc/Desktop/Java/day32/a.txt");
    OutputStream outputStream = new FileOutputStream("/Users/cc/Desktop/Java/day32/b.txt");
    // 3. 使用流
    // ⚠️ write方法会覆盖原文件的内容
    int r;
    // 读取流
    while ((r = inputStream.read()) != -1) {
      // 输出流
      outputStream.write(r);
    }
    // outputStream.write(bytes, 0, 3);
    // 4. 关闭流 先开的后关 后开的先关
    outputStream.close();
    inputStream.close();
  }
}